﻿@model System.Collections.IList

@{
    ViewBag.Title = "MenuInfo";
    Layout = "~/Views/Shared/_BaseLayout.cshtml";
    var X = Html.X();
}

@section example
{
    <h2>MenuInfo</h2>
    @(X.Viewport()
        .Layout(LayoutType.Border)
        .Items(
                X.Panel()
                  .Region(Region.Center)
                  .Margins("5 5 5 5")
                  .Items(
                        X.GridPanel()
                            .ID("gpMenuInfo")
                            .Region(Region.Center)
                            .Title("MenuInfo")
                            .Store(X.Store()
                                    .Model(X.Model()
                                        .Fields(
                                                new ModelField("MenuCode", ModelFieldType.String),
                                                new ModelField("MenuName", ModelFieldType.String),
                                                new ModelField("ActionName", ModelFieldType.String),
                                                new ModelField("ControllerName", ModelFieldType.String),
                                                new ModelField("URL", ModelFieldType.String)
                                                )
                                            )
                                    .DataSource(Model)
                                    )
                            .ColumnModel(
                                        X.Column().Text("MenuCode").DataIndex("MenuCode").Flex(1),
                                        X.Column().Text("MenuName").DataIndex("MenuName").Flex(1),
                                        X.Column().Text("ActionName").DataIndex("ActionName"),
                                        X.Column().Text("ControllerName").DataIndex("ControllerName"),
                                        X.Column().Text("URL").DataIndex("URL")
                            )
                            .TopBar(
                                Html.X().Toolbar()
                                    .Items(
                                Html.X().Button()
                                    .Text("Add record")
                                    .Icon(Icon.Add)
                                    .Handler("addRecord(this.up('grid'));"),

                                Html.X().Button()
                                    .Text("Delete selected")
                                    .Icon(Icon.Delete)
                                    .Handler("deleteSelected(this.up('grid'));"),

                                Html.X().ToolbarFill(),

                                Html.X().Button()
                                    .Text("Find 'Government Motors'")
                                    .Icon(Icon.Find)
                                    .Handler("selectRecord(this.up('grid'), 'Government Motors Corporation');"),

                                Html.X().Button()
                                    .Text("To XML")
                                    .Icon(Icon.PageCode)
                                    .Handler("exportData(this.up('grid'));"),

                                Html.X().Button()
                                    .Text("Selection To XML")
                                    .Icon(Icon.PageCode)
                                    .Handler("exportData(this.up('grid'), true);"),

                                Html.X().Button()
                                    .Text("Save")
                                    .Icon(Icon.Disk)
                                    .DirectEvents(de =>
                                    {
                                        de.Click.Url = Url.Action("Sync");
                                        de.Click.ExtraParams.Add(new Parameter
                                        {
                                            Name = "data",
                                            Value = "this.up('grid').store.getChangedData()",
                                            Mode = ParameterMode.Raw,
                                            Encode = true
                                        });
                                    })
                            )
                    )
                         )
               )
    )
}
